package com.blb.day1thread;

public class ThreadTest2 {

    public static void main(String[] args) {

        Thread thread = new Thread(() -> {
            for(int i = 0;i < 1000;i++){
                if(i == 500)
                try {
                    Thread.sleep(100);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println("当前线程是: " + Thread.currentThread().getName() + "---" + i);
            }
        });
        thread.start();
        Thread thread2 = new Thread(() -> {
            for(int i = 0;i < 1000;i++){
                System.out.println("当前线程是: " + Thread.currentThread().getName() + "---" + i);
            }
        });
        thread2.start();
//        thread.start();
//        thread.run();
//        for(int i = 0;i < 1000;i++){
//            System.out.println("当前线程是: " + Thread.currentThread().getName() + "---" + i);
//        }
    }
}
